package com.boot.mall.third.controller;

import com.boot.common.utils.R;
import com.boot.mall.third.service.EmailSendService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

@Controller
public class EmailSendController {

    @Autowired
    private EmailSendService emailSendService;

    @ResponseBody
    @GetMapping("/ems/sendEmail")
    public R sendEmail(@RequestParam("code") String code, @RequestParam("email") String email){
        long l1 = System.currentTimeMillis();
        boolean result = emailSendService.sendEmail(code, email);
        System.out.println(System.currentTimeMillis() - l1);
        if (result){
            return R.ok();
        }else {
            return R.error();
        }
    }

}
